# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=cmocka
pkgver=1.1.7
pkgrel=2
pkgdesc="An elegant unit testing framework for C with support for mock objects"
url="https://cmocka.org/"
arch="all"
license="Apache-2.0"
makedepends="cmake samurai"
subpackages="$pkgname-dev"
source="https://cmocka.org/files/${pkgver%.*}/cmocka-$pkgver.tar.xz
	wordsize.patch
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DUNIT_TESTING=ON
	cmake --build build
}

check() {
	cd "$builddir"/build

	# If some tests fail, run them again in verbose mode.
	ninja test || ctest --rerun-failed --extra-verbose
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
fe451893474dce1270e12af707a9a8fe1f0217e1782b4e1a67d25dadf56ff4a5e7dbc9ba4431f774aedffa46a40a28a6a0488df24feefb2f93e90fd2369c2c88  cmocka-1.1.7.tar.xz
060595aba90467b4d552cae7f0228d73ead2af32cd6a501ddfd5c5cdfd23d3ba397c795c7678bfa1d1e52ab54bebdcfb49ee5c7dd6adab48b41d392db6f3fef1  wordsize.patch
"
